import os

def findRootDir(curPath):
    # 得到当前目录下所有的文件
    fileList = os.listdir(curPath)
    # git根目录作为项目根目录
    if fileList.count('.git'):
        return curPath
    parPath = os.path.dirname(curPath)
    if parPath == os.path.dirname(parPath):
        return ""
    return findRootDir(parPath)

print(findRootDir(os.getcwd()))

def findInclude(curPath, list2include):
    # 得到当前目录下所有的文件
    fileList = os.listdir(curPath)
    for fileName in fileList:
        fileAbsPath = os.path.join(curPath, fileName)
        # 判断是否是目录（用绝对路径）
        if os.path.isdir(fileAbsPath):
            if fileName == 'include':
                list2include.extend(['-I', fileName])
            findInclude(fileAbsPath, list2include)

lib = []
findInclude(findRootDir(os.getcwd()), lib)
print(lib)
